package com.fanhao.dllo.soundfm.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.fanhao.dllo.soundfm.entity.RecommendResult;
import com.fanhao.dllo.soundfm.fragment.Infofragmnet.RecommentViewPagerFragment;

import java.util.List;

/**
 * Created by dllo on 16/1/12.
 */
public class RecomViewPageAdapter extends FragmentPagerAdapter {
    private List<RecommendResult.FocusImagesEntity.ListEntity> list;

    public List<RecommendResult.FocusImagesEntity.ListEntity> getList() {
        return list;
    }

    public void addData(List<RecommendResult.FocusImagesEntity.ListEntity> list) {
        this.list = list;
        notifyDataSetChanged();
    }

    public RecomViewPageAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        RecommendResult.FocusImagesEntity.ListEntity listEntity
                = list.get(position % list.size());
        String imgUrl = listEntity.getPic();
        return RecommentViewPagerFragment.getInstance(imgUrl,position % list.size(),list);
    }

    @Override
    public int getCount() {
        return list != null && list.size() > 0 ? Integer.MAX_VALUE : 0;
    }

}
